<template>
	<view>
		<view class="flexcolumn">
			<image :src="ewm" style="width: 100%;height: 100vh;" mode="" @longpress="show=true"></image>
			<!-- <view class="xiaohui margin_top6">扫描上方二维码添加客服</view> -->
		</view>
		<u-action-sheet :actions="list" @select="selectClick" closeOnClickOverlay @close="show=false" :show="show"></u-action-sheet>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				ewm: "",
				list: [{
						name: '保存图片'
					},
				],
				show: false
			}
		},
		onLoad() {
			this.init()
		},
		onShareAppMessage() {
			let _this = this
			return {
				title: "趣调研",
				path: "pages/index/index?code=" + uni.getStorageSync("invite_code"),
			}
		},
		onShareTimeline: function() {
			return {
				title: "趣调研",
				path: "pages/index/index?code=" + uni.getStorageSync("invite_code"),
			}
		},
		methods: {
			selectClick(e){
				let _this = this
				uni.downloadFile({ //下载文件资源到本地,返回文件的本地临时路径
				 	url: _this.ewm, //网络图片路径
					success:(res) => {
						var imageUrl = res.tempFilePath; //临时文件路径
						uni.saveImageToPhotosAlbum({ //保存图片到系统相册
							filePath: imageUrl,
							success: (res) => {
								httpRequest.toast("图片保存成功")
							},
							fail: (err) => {
								httpRequest.toast("图片保存失败")
							}
						})
					}
				})
			},
			init() {
				httpRequest.request('/api/index/getConfigInfo', 'GET', {}).then(resp => {
					this.ewm = resp.data.qywechar_image
				})
			},
		}
	}
</script>

<style>

</style>